{% extends "CommonLibraryBundle::base.html.twig" %}

{% block stylesheets %}
    {{ parent() }}
    <link type="text/css" rel="stylesheet" href="{{asset('css/theme.css')}}" />
{% endblock %}

{% block javascripts %}
    {{parent()}}
{% endblock %}

{% block titre %}
    Thème
{% endblock %}

{% block titresmall %}
    {{ chemin|raw }}
{% endblock %}

{% block notif %}
    {% include '::notif.html.twig' %}
{% endblock %}

{% block subbody %}
    <script type="text/javascript">
    </script>

    <div id="divGestionTheme" class="row">
        <div class="col-md-12">
            {% if(ajoutTheme) %}
                <a href="{{ path("common_library_theme_edit", {'idThemeParent': idTheme }) }}" class="btn btn-mini btn-ajout btn-primary">Ajouter un thème</a>
            {% endif %}
            {% if(app.request.attributes.get('_route') == 'common_library_theme_index_1' and idTheme != 0) %}
                <a href="{{ path("common_library_qcm_edit", {'idTheme': idTheme}) }}" class="btn btn-mini btn-ajout btn-primary">Ajouter un QCM</a>
            {% endif %}
        </div>
        {% if app.request.attributes.get('_route') == 'common_library_theme_index_1' and idTheme != 0 %}
            <div class="col-md-12 tabs-theme">
                <ul class="nav nav-tabs nav-justified nav-violet">
                    <li class="active"><a href="#theme" data-toggle="tab">Sous-thème</a></li>
                    <li><a href="#qcm" data-toggle="tab">QCM</a></li>
                </ul>
            </div>
        {% endif %}
        <div class="tab-content tab-content-theme">
            {% if app.request.attributes.get('_route') != 'common_library_theme_index' %}
                <div class="tab-pane active" id="theme">
            {% endif %}
                {% if themesActif|length > 0 %}
                    {% for theme in themesActif %}
                        <div class="col-md-3 bloc-theme">
                            <table class="table-condensed">
                                <tr>
                                    <td><a href="{{ path("common_library_theme_edit_1", {'idTheme': theme.id, 'idThemeParent': idTheme }) }}"><button class="btn btn-info btn-xs"><i class="glyphicon glyphicon-edit"></i></button></a></td>
                                    <td rowspan="2">
                                        <a href="{{ path("common_library_theme_index_1", {'idTheme': theme.id}) }}">{{ theme.nom }}</a>
                                    </td>
                                </tr>
                                <tr>
                                    <td><a href="{{ path("common_library_theme_desactive", {'idTheme': theme.id}) }}" onclick="return confirm('Etes-vous sûr(e) de vouloir désactiver le thème {{ theme.nom }} ?')"><button class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove"></i></button></a></td>
                                </tr>
                            </table>
                        </div>
                    {% endfor %}
                {% endif %}
                {% if themesInactif|length > 0 and themesActif|length > 0 %}
                    <div class="col-md-12 barre-theme"></div>
                {% endif %}
                {% if themesInactif|length > 0 %}
                    {% for theme in themesInactif %}
                        <div class="col-md-3 bloc-theme bloc-desactive">
                            <table class="table-condensed">
                                <tr>
                                    <td><a href="{{ path("common_library_theme_edit_1", {'idTheme': theme.id, 'idThemeParent': idTheme }) }}"><button class="btn btn-info btn-xs"><i class="glyphicon glyphicon-edit"></i></button></a></td>
                                    <td rowspan="2">
                                        <a href="{{ path("common_library_theme_index_1", {'idTheme': theme.id}) }}">{{ theme.nom }}</a>
                                    </td>
                                </tr>
                                <tr>
                                    <td><a href="{{ path("common_library_theme_active", {'idTheme': theme.id}) }}" onclick="return confirm('Etes-vous sûr(e) de vouloir activer le thème {{ theme.nom }} ?')"><button class="btn btn-success btn-xs"><i class="glyphicon glyphicon-ok"></i></button></a></td>
                                </tr>
                            </table>
                        </div>
                    {% endfor %}
                {% endif %}
            {% if app.request.attributes.get('_route') != 'common_library_theme_index' %}
                </div>
            {% endif %}
            <div class="tab-pane" id="qcm">
                {% if qcmsActif|length >0 %}
                    {% for qcm in qcmsActif %}
                        <div class="col-md-3 bloc-theme">
                            <table class="table-condensed">
                                <tr>
                                    <td><a href="{{ path("common_library_qcm_edit_1", {'idTheme': idTheme, 'idQcm': qcm.id }) }}"><button class="btn btn-info btn-xs"><i class="glyphicon glyphicon-edit"></i></button></a></td>
                                    <td rowspan="2">
                                        <a href="#">{{ qcm.nom }}</a>
                                    </td>
                                </tr>
                                <tr>
                                    <td><a href="{{ path("common_library_qcm_desactive", {'idQcm': qcm.id}) }}" onclick="return confirm('Etes-vous sûr(e) de vouloir désactiver le QCM {{ qcm.nom }} ?')"><button class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove"></i></button></a></td>
                                </tr>
                            </table>
                        </div>
                    {% endfor %}
                {% endif %}
                {% if qcmsInactif|length > 0 and qcmsActif|length > 0 %}
                    <div class="col-md-12 barre-theme"></div>
                {% endif %}
                {% if qcmsInactif|length > 0 %}
                    {% for qcm in qcmsInactif %}
                        <div class="col-md-3 bloc-theme bloc-desactive">
                            <table class="table-condensed">
                                <tr>
                                    <td><a href="#"><button class="btn btn-info btn-xs"><i class="glyphicon glyphicon-edit"></i></button></a></td>
                                    <td rowspan="2">
                                        <a href="#">{{ qcm.nom }}</a>
                                    </td>
                                </tr>
                                <tr>
                                    <td><a href="{{ path("common_library_qcm_active", {'idQcm': qcm.id}) }}" onclick="return confirm('Etes-vous sûr(e) de vouloir activer le QCM {{ qcm.nom }} ?')"><button class="btn btn-success btn-xs"><i class="glyphicon glyphicon-ok"></i></button></a></td>
                                </tr>
                            </table>
                        </div>
                    {% endfor %}
                {% endif %}
            </div>
        </div>
    </div>

{% endblock %}